#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>

#include "im2d.h"
#include "rga.h"
#include "RgaUtils.h"

#include "rknn_api.h"
#include "postprocess.h"

#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
typedef struct {
  rknn_context rknn_ctx;
  rknn_input_output_num io_num;
  rknn_tensor_attr* input_attrs;
  rknn_tensor_attr* output_attrs;
  int model_channel;
  int model_width;
  int model_height;
  FILE* out_fp;
} rknn_app_context_t;

void dump_tensor_attr(rknn_tensor_attr* attr);
double __get_us(struct timeval t);
unsigned char* load_data(FILE* fp, size_t ofst, size_t sz);
unsigned char* read_file_data(const char* filename, int* model_size);
int init_model(const char* model_path, rknn_app_context_t* app_ctx);
int release_model(rknn_app_context_t* app_ctx);
int inference_model(rknn_app_context_t* app_ctx, cv::Mat img, detect_result_group_t* detect_result);